﻿Public Class DaoKhachHang
    Public Shared Function Lay() As DataTable
        Dim bang As DataTable = Nothing
        Try
            Dim data As New DataProvider
            Dim query As String = "select * from KhachHang"
            bang = data.ExecuteQuery(query)
        Catch ex As Exception
            Throw New Exception(ex.Message.ToString())
        End Try
        Return bang
    End Function
    Public Shared Function Them(ByVal ma As String, ByVal ten As String, ByVal dc As String, ByVal no As Double) As String
        Dim err As String = String.Empty
        Try
            Dim data As New DataProvider
            Dim query As String = "insert into KhachHang values('" & ma & "',N'" & ten & "',N'" & dc & "','" & no & "')"
            data.ExecuteQuery(query)
        Catch ex As Exception
            err = ex.Message.ToString()
        End Try
        Return err
    End Function
    Public Shared Function Capnhat(ByVal ma As String, ByVal ten As String, ByVal dc As String, ByVal no As Double) As String
        Dim err As String = String.Empty
        Try
            Dim data As New DataProvider
            Dim query As String = "update KhachHang set Tenkh=N'" & ten & "',Diachi=N'" & dc & "',Nodauki='" & no & "' where Makh='" & ma & "'"
            data.ExecuteQuery(query)
        Catch ex As Exception
            err = ex.Message.ToString()
        End Try
        Return err
    End Function
    Public Shared Function Xoa(ByVal ma As String) As String
        Dim err As String = String.Empty
        Try
            Dim data As New DataProvider
            Dim query As String = "delete from KhachHang where Makh='" & ma & "'"
            data.ExecuteQuery(query)
        Catch ex As Exception
            err = ex.Message.ToString()
        End Try
        Return err
    End Function
End Class
